<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>yukari world</title>
<#include "/lib/base_source.ftl">
<style type="text/css">
</style>
</head>
<body>

<div class='whole-container'>
<#include "/lib/header.ftl">
    <div>
        <ul class="breadcrumb">
        	<li>兑换管理</li><span class="divider">/</span>
            <li>物品列表</li>
        </ul>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="container span12">
            <#include "/lib/alert.ftl">

                <div class='main-content'>
                    <div class="well form-inline">
                        <a class="btn btn-sm btn-primary" href="${rc.contextPath}/admin/exchange/gfit/add">添加物品</a>
                        <a class="btn btn-sm btn-info" href="${rc.contextPath}/admin/exchange/history/list">房管兑换记录</a>
                    </div>

                    <div class="table-content">
                        <table class="table table-striped table-bordered table-condensed" id="itemTable" style="font-size:12px;word-break:break-all;word-wrap:break-word;">
                            <tr>
                                <th>编号</th>
                                <th>物品名</th>
                                <th>样图（点击放大）</th>
                                <th>兑换价格(积分)</th>
                                <th>库存</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            <#list list as item>
                                <tr>
                                    <td>${item.id}</td>
                                    <td>${item.name}</td>
                                    <td><#if item.image != ''><a href="http://image.loveyukari.com/${item.image}"  target="_blank" ><img src="http://image.loveyukari.com/${item.image}" style="max-width: 200px;" /></a></#if></td>
                                    <td>${item.price}</td>
                                    <td>${item.num}</td>
                                    <td><#if item.status == 1>上架<#else>下架</#if></td>
                                    <td>
                                        <a class="btn btn-sm btn-info" href="${rc.contextPath}/admin/exchange/gfit/update?id=${item.id}">修改</a>
                                        <#if item.status == 1>
                                        <a class="btn btn-sm btn-danger" href="javascript:" onclick="updateGfitStatus(${item.id})">下架</a>
                                        <#else>
                                        <a class="btn btn-sm btn-success" href="javascript:" onclick="updateGfitStatus(${item.id})">上架</a>
                                        </#if>

                                    </td>
                                </tr>
                            </#list>
                        </table>
                    <#-- table -->

                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
<script>

    $(document).ready(function(){
    });


    function updateGfitStatus (id) {
        $.ajax({
            url : "${rc.contextPath}/admin/exchange/gfit/updateStatus",
            dataType : "json",
            data :  {"id":id},
            type:'post',
            success:function(json){
                if (json.code == 0){
                    location.reload();
                } else {
                    alert("添加失败: "+json.message);
                }
            }
        });
    }



</script>
</body>
</html>